<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page contentType="text/html; charset=UTF-8" language="java"%>
<%@ taglib uri="http://struts.apache.org/tags-html"  prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean"  prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@page import="com.kcs.common.utils.commonUtils"%>
<%@page import="com.kcs.common.utils.PropsUtils"%>
<%@page import="com.kcs.common.utils.Constant"%>

<html>
<head>
<title>FX Margin - End Of Day</title>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script type="text/javascript" src="jsp/script/jquery/plugin/fancybox/jquery.easing-1.3.pack.js"></script>
<script type="text/javascript" src="jsp/script/jquery/plugin/fancybox/jquery.fancybox-1.3.4.js"></script>
<script type="text/javascript" src="jsp/script/jquery/plugin/fancybox/jquery.fancybox-1.3.4.pack.js"></script>   
<script type="text/javascript" src="jsp/script/jsDatePick.full.1.3.js"></script>   	 	 	
<script type="text/javascript" src="jsp/script/common.js"></script>  
<link rel="stylesheet" type="text/css" href="jsp/script/jquery/plugin/fancybox/jquery.fancybox-1.3.4.css"/>
<link rel="stylesheet" type="text/css" href="jsp/css/table.css"/>
<link rel="stylesheet" type="text/css" href="jsp/css/fxmarginStyle.css"/>
<link rel="stylesheet" type="text/css" href="jsp/css/jsDatePick_ltr.css" />

<script type="text/javascript">
	function runFXEndOfDay(){
		var tranCode = document.getElementsByName("tranCode")[0];
		tranCode.value = "runFXEndOfDay";
		
		document.forms[0].submit();
	}
	
	function callDealCenter(){
		var tranCode = document.getElementsByName("tranCode")[0];
		tranCode.value = "callDealsCenter";
		
		document.forms[0].submit();
	}

	function testLog(){
		var tranCode = document.getElementsByName("tranCode")[0];
		tranCode.value = "testLog";
		
		document.forms[0].submit();
	}

	function callArchiveData(){
		var tranCode = document.getElementsByName("tranCode")[0];

		if(confirm("ระบบจะทำการลบข้อมูลต้องการดำเนินการต่อหรือไม่?")){
			tranCode.value = "callArchiveData";
			
			document.forms[0].submit();
		}
	}

	function testFileService(){
		var tranCode = document.getElementsByName("tranCode")[0];
		tranCode.value = "testFileService";
		
		document.forms[0].submit();
	}

	window.onload=function(){
		new JsDatePick({
			useMode:2,
			target:"inStartDate",
			dateFormat:"%d/%m/%Y"});

		new JsDatePick({
			useMode:2,
			target:"inEndDate",
			dateFormat:"%d/%m/%Y"});

		/*new JsDatePick({
			useMode:2,
			target:"inWsStartDate",
			dateFormat:"%d/%m/%Y"});

		new JsDatePick({
			useMode:2,
			target:"inWsEndDate",
			dateFormat:"%d/%m/%Y"});*/


		var testCBS = jQuery("#testCBS").val();
		var testOracle = jQuery("#testOracle").val();

		if(testCBS == "true") alert("CBS pass");
		if(testOracle == "true") alert("Oracle pass");
		
	}

	function testCBSFunction() {
		var tranCode = document.getElementsByName("tranCode")[0];
		tranCode.value = "testCBS";
		
		document.forms[0].submit();
	}

	function testOracleFunction() {
		var tranCode = document.getElementsByName("tranCode")[0];
		tranCode.value = "testOracle";
		
		document.forms[0].submit();
	}

	function inquiryAccountStatement() {
		var tranCode = document.getElementsByName("tranCode")[0];
		tranCode.value = "inquiryAccountStatement";
		
		document.forms[0].submit();
	}
	

</script>
	
</head>
<body>
	<!-- HEADER MENU -->
	<%@ include	file="include/headerMenu.jsp"%> 
		<center>
			<div id="divEndOfDay" style="width:95%">
					<html:form action="/FXEndOfDayAction.do" style="margin:0px;">
						<html:hidden property="tranCode"/>
						
						<br/>
						<br/>
						<br/>
						<h1>Test for Admin</h1>
						<br/>

						
						<%@ include	file="include/popupCustomer.jsp"%> 
						
						<table width="60%" border="1">
							<tr>
								<td width="25%" align="right">Batch :</td>
								<td width="75%" align="left"><input type="button" class="button" value="Run" onClick="runFXEndOfDay();"/></td>
							</tr>
							<tr>
								<td width="25%" align="right">Test Connection :</td>
								<td width="75%" align="left"><input type="button" class="button" value="Deal Center" onClick="callDealCenter();"/></td>
							</tr>
							<tr>
								<td width="25%" align="right">Archive Data :</td>
								<td width="75%" align="left">
									Start Date:
									<input type="text" id="inStartDate" name="inStartDate"/>
									&nbsp;
									End Date:
									<input type="text" id="inEndDate" name="inEndDate"/>
									&nbsp;
									<input type="button" class="button" value="Archive Data" onClick="callArchiveData();"/>
								</td>
							</tr>
							<tr>
								<td width="25%" align="right">Test Connection :</td>
								<td width="75%" align="left">
									<br/>
									CIF No. : <html:text property="cifNo" value="205633"></html:text><br/>
									As of date : <html:text property="asOfDate" value="14/10/2013"></html:text><br/>
									Margin A/C Co : <html:text property="marginAccCode" value="6054064"></html:text>
									&nbsp;		
									<input type="button" class="button" value="Test CBS" onClick="testCBSFunction();"/><br/>	
									<input type="hidden" id="testCBS" 		value="<%=request.getAttribute("testCBS")%>"/>
									
									
								</td>
							</tr>
							<tr>
								<td width="25%" align="right">Test Connection :</td>
								<td width="75%" align="left">
									<input type="button" class="button" value="Test RET-AD" onClick="testOracleFunction();"/>	
									<input type="hidden" id="testOracle" 	value="<%=request.getAttribute("testOracle")%>"/>
								</td>
							</tr>
						</table>
						<br/>
						<br/>
													
						<%
							Object err = request.getAttribute(Constant.ERR_ATTR);
							if(err != null){
								out.print("<font color='red'>"+err+"</font>");
							}
						%>

						<!-- <input type="button" class="button" value="Test Log" onClick="testLog();"/>  -->
						<br/>
						<br/>
						<br/>
						<br/>
						<br/>
						<br/>

						
						<!--  <input type="button" class="button" value="Test File Service Data" onClick="testFileService();"/>  -->
						<br/><br/>			
						<br/><br/>
						<br/><br/>
						
						<!-- <b>Test WS InquiryAccountStatement</b>
						<br/><br/>
						Cif No:
						<html:text styleId="inWsCifNo" name="FXEndOfDayActionForm" property="inWsCifNo"/>
						<br/>
						ACC No:
						<html:text styleId="inWsAccNo" name="FXEndOfDayActionForm" property="inWsAccNo"/>
						<br/>
						Start Date:
						<html:text styleId="inWsStartDate" name="FXEndOfDayActionForm" property="inWsStartDate"/>
						&nbsp;
						End Date:
						<html:text styleId="inWsEndDate" name="FXEndOfDayActionForm" property="inWsEndDate"/>
						<br/>
						<input type="button" class="button" value="Test WS" onClick="inquiryAccountStatement();"/>
						<br/><br/><br/><br/>
						<br/><br/><br/><br/>
						&nbsp;
						 -->
						 
						<logic:present name="resultMessage">
							<script type="text/javascript">
								alert('<%=request.getAttribute("resultMessage")%>');
							</script>
						</logic:present>
					</html:form>
			</div>
		</center>
</body>
</html>